<?
/**
 * phpmailer发送邮件的封装类
 * */
class PHPMailerUtil {
	/**
	 * 通过crs发送邮件
	 * @param $fromName 邮件发送方的名称
	 * @param $to 需要发送的邮件地址
	 * @param $subject 邮件标题
	 * @param $body 邮件正文
	 * */
	public static function send($fromName, $to, $subject, $body, $isHTML = true, $charset="GBK") {
		$mail = new PHPMailer(); 
		$mail->IsSMTP();
		$mail->Host = "smtp.163.com";
		$mail->SMTPAuth = true;
		$mail->Username = "shenzhe__@163.com"; //改成你的email
		$mail->Password = "";//你的密码
		
		$mail->WordWrap = 50;
		$mail->CharSet = $charset;
		$mail->IsHTML($isHTML);
		$mail->Encoding = "base64";

		$mail->From = "shenzhe__@163.com"; 
		$mail->FromName = iconv("UTF-8", $charset, $fromName);
		$mail->AddAddress($to);
		#$mail->AddBCC("stevema@luopan.com","马叔");
		$mail->AddReplyTo($to,iconv("UTF-8", $charset, "该邮件为系统自动发送，请勿回复邮件")); 

		$mail->Subject = iconv("UTF-8", $charset, $subject);
		$mail->Body = iconv("UTF-8", $charset, $body);
		if($isHTML) {
			$mail->AltBody = iconv("UTF-8", $charset, "这是一封HTML邮件，请以HTML方式浏览"); 
		}
		if(!$mail->Send()) {
			return $mail->ErrorInfo;
		}
	}
}
?>